package com.lolxxs.controller;


import com.lolxxs.model.User;
import com.lolxxs.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chenyanting
 * @since 2022-04-03
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    @Qualifier("userServiceImpl")
    private IUserService userService;

    @GetMapping("/query/{id}")
    public User getUserById(@PathVariable("id") long id) {
        return userService.getUserById(id);
    }




    @PostMapping("/update")
    public User updateUser(@RequestBody User user) {
        return userService.updateUser(user.getId(),user);
    }

    @PostMapping("/delete/{id}")
    public String deleteUserById(@PathVariable("id") long id) {
        userService.deleteUserById(id);
        return "删除成功";
    }
}
